<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>礼包管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
    <style>
        .search-container .layui-form-select, .search-container input[type=text] {
            width: 212px!important;
        }
    </style>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <div class="layui-tab-item layui-show">
                <div class="layui-tab layui-tab-brief" lay-filter="progress">
                    <ul class="layui-tab-title" id="zc_tab">
                        <li ${gift.progress == 1 ? 'class="layui-this"' : ''} data-progress="1">正在发放</li>
                        <li ${gift.progress == 2 ? 'class="layui-this"' : ''} data-progress="2">未开始</li>
                        <li ${gift.progress == 3 ? 'class="layui-this"' : ''} data-progress="3">已结束</li>
                    </ul>
                    <div class="layui-tab-content">
                        <form class="layui-form" action="${ctx}/gift/gift/list.do" id="myForm" method="post">
                            <input type="hidden" name="pageNo" id="pageNo" value="${page.page}"/>
                            <input type="hidden" name="progress" id="progress" value="${gift.progress}"/>
                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">发放对象</label>
                                            <div class="layui-input-inline">
                                                <select name="condition">
                                                    <option value="">全部</option>
                                                    <c:forEach var="map" items="${typeMap}">
                                                        <c:if test="${gift.condition == map.key}">
                                                            <option value="${map.key}" selected="selected">${map.value}</option>
                                                        </c:if>
                                                        <c:if test="${gift.condition != map.key}">
                                                            <option value="${map.key}">${map.value}</option>
                                                        </c:if>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">礼包名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="name" autocomplete="off" class="layui-input" value="${gift.name}" placeholder="请输入查询礼包名称">
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">礼包类型</label>
                                            <div class="layui-input-inline">
                                                <select name="model">
                                                    <option value="">全部</option>
                                                    <option value="1" ${gift.model == 1 ? 'selected' : ''}>虚拟</option>
                                                    <option value="2" ${gift.model == 2 ? 'selected' : ''}>实物</option>
                                                    <option value="3" ${gift.model == 3 ? 'selected' : ''}>广告链接</option>
                                                </select>
                                            </div>
                                        </li>
                                        <%--<li class="form-item-inline"><label class="search-form-lable">项目名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="targetName" autocomplete="off" class="layui-input" value="${gift.targetName}" placeholder="请输入查询项目名称">
                                            </div>
                                        </li>--%>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item"><label class="search-form-lable">发放时间</label>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="startDate" value="${gift.startDate}" placeholder="开始日期">
                                                </div>
                                                -
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="endDate" value="${gift.endDate}" placeholder="结束日期">
                                                </div>
                                            </div>
                                            <div class="cl"></div>
                                        </li>
                                        <li class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                                <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item"><label class="search-form-lable">应用场景</label>
                                            <div class="check-btn-inner" id="type">
                                                <a href="javascript:void(0);" onclick="setTimeType($(this), null,'#myForm')" ${empty gift.type ? 'class="active"' : ''}>全部</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),'ZC_ACTIVITY','#myForm')" ${gift.type == 'ZC_ACTIVITY' ? 'class="active"' : ''}>众筹</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),'ACTIVITY','#myForm')" ${gift.type == 'ACTIVITY' ? 'class="active"' : ''}>活动</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),'ARTICLE','#myForm')" ${gift.type == 'ARTICLE' ? 'class="active"' : ''}>文章</a>
                                                <a href="javascript:void(0);" onclick="setTimeType($(this),'GOODS','#myForm')" ${gift.type == 'GOODS' ? 'class="active"' : ''}>玩法</a>
                                                <input type="hidden" name="type" value="${gift.type}"/>
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item"><label class="search-form-lable">更新时间</label>
                                            <div class="check-btn-inner" id="timeType">
                                                <a id="all" href="javascript:void(0);"
                                                   onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                                <input type="hidden" name="timeType" value="${input.timeType}"/>
                                            </div>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createStart" value="${input.createStart}" placeholder="开始日">
                                                </div>
                                                -
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createEnd" value="${input.createEnd}" placeholder="截止日">
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </form>
                        <div class="list-content">
                            <div class="cl">
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="100px">
                                        <col width="100px">
                                        <col width="100px">
                                        <col>
                                        <%--<col>--%>
                                        <col width="100px">
                                        <col>
                                        <col width="90px">
                                        <col width="90px">
                                        <col width="90px">
                                        <col>
                                        <col>
                                    </colgroup>
                                    <thead>
                                        <tr>
                                            <th>应用场景</th>
                                            <th>发放对象</th>
                                            <th>礼包类型</th>
                                            <th>礼包名称</th>
                                            <%--<th>众筹项目名称</th>--%>
                                            <th>礼包价值</th>
                                            <th>发放时间</th>
                                            <th>项目数量</th>
                                            <th>发放数量</th>
                                            <th>领取数量</th>
                                            <th>更新时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <c:forEach var="giftt" items="${giftList}">
                                            <tr>
                                                <td>
                                                    <c:choose>
                                                        <c:when test="${giftt.type == 'ZC_ACTIVITY'}">众筹</c:when>
                                                        <c:when test="${giftt.type == 'ACTIVITY'}">活动</c:when>
                                                        <c:when test="${giftt.type == 'ARTICLE'}">文章</c:when>
                                                        <c:when test="${giftt.type == 'GOODS'}">玩法</c:when>
                                                    </c:choose>
                                                </td>
                                                <td>
                                                    <c:choose>
                                                        <c:when test="${giftt.condition == 'ZC_SUPPORT'}">众筹支持</c:when>
                                                        <c:when test="${giftt.condition == 'ZC_APPLY'}">众筹报名</c:when>
                                                        <c:when test="${giftt.condition == 'ZC_ING'}">众筹鼓励</c:when>
                                                        <c:when test="${giftt.condition == 'ZC_SUCCESS'}">众筹成功</c:when>
                                                    </c:choose>
                                                </td>
                                                <td>
                                                    <c:if test="${giftt.model == 1}">虚拟</c:if>
                                                    <c:if test="${giftt.model == 2}">实物</c:if>
                                                    <c:if test="${giftt.model == 3}">广告链接</c:if>
                                                </td>
                                                <td class="ellipsis-1">${giftt.name}</td>
                                                <%--<td class="ellipsis-1">${giftt.targetName}</td>--%>
                                                <td><fmt:formatNumber value="${giftt.price}" pattern="0.00" />元</td>
                                                <td><fmt:formatDate value="${giftt.startTime}" pattern="yyyy-MM-dd"/>&nbsp;至&nbsp;<fmt:formatDate value="${giftt.endTime}" pattern="yyyy-MM-dd"/></td>
                                                <td>${giftt.targetNum}</td>
                                                <td>${giftt.stock}</td>
                                                <td>${giftt.salesNum}</td>
                                                <td><fmt:formatDate value="${giftt.updateDate}" pattern="yyyy-MM-dd HH:mm"/></td>
                                                <td class="opts-btns tb-opts">
                                                    <div class="comm-opts">
                                                        <a class="green" href="${ctx}/gift/gift/toForm.do?giftId=${giftt.id}">编辑</a>
                                                        <a class="red" href="javascript:txz.deleteObject('确定要删除该礼包吗？', '${ctx}/gift/gift/delete.do?giftId=${giftt.id}');">删除</a>
                                                        <c:if test="${giftt.model != 3}">
                                                            <a href="${ctx}/gift/gift/giftOrderList.do?giftId=${giftt.id}">领取用户列表</a>
                                                        </c:if>
                                                        <a href="${ctx}/gift/gift/giftTargetList.do?giftId=${giftt.id}">项目列表</a>
                                                    </div>
                                                </td>
                                            </tr>
                                        </c:forEach>
                                        <c:if test="${page.totalCount == 0}">
                                            <tr class="f16 tc mt15">
                                                <td colspan="11">还没有礼包数据</td>
                                            </tr>
                                        </c:if>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div id="page_content" class="page-container"></div>
                    </div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">

    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>
    $(function () {
        // 加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['laypage', 'element', 'laydate'], function () {
            var laydate = layui.laydate, element = layui.element;
            element.on('tab(progress)', function (data) {
                var progress = $("li.layui-this").attr("data-progress");
                $("#myForm #progress").val(progress);
                $("#myForm").submit();
            });

            // 查询开始日期
            var start = {
                elem: 'input[name=startDate]'
            };

            var end = {
                elem: 'input[name=endDate]'
            };
            laydate.render(start);
            laydate.render(end);

            // 查询开始日期
            var start = {
                elem: 'input[name=s_start]'
            };

            var end = {
                elem: 'input[name=s_end]'
            };
            laydate.render(start);
            laydate.render(end);

            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    });
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '礼包管理',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
        btns:[{
            name: '发布礼包',
            icon: 'add',
            href: '${ctx}/gift/gift/toForm.do'
        }]
    });
</script>
</body>
</html>